import { FormSchema, BasicColumn } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { getToken } from '/@/utils/auth';

import { userFields } from '/@/views/system/user/user.data';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n('monitor.onlineuser');
//列表
export const columns: BasicColumn[] = [
  {
    title: userFields.username,
    align: 'center',
    dataIndex: 'username',
    customRender: ({ text, record }: { text: any; record: any }) => {
      const token = getToken();
      if (record.token === token) {
        return text + t('me');
      }
      return text;
    },
  },
  {
    title: userFields.realname,
    align: 'center',
    dataIndex: 'realname',
  },
  {
    title: userFields.avatar,
    align: 'center',
    width: 120,
    dataIndex: 'avatar',
    customRender: render.renderAvatar,
  },
  {
    title: userFields.birthday,
    align: 'center',
    dataIndex: 'birthday',
  },
  {
    title: userFields.sex,
    align: 'center',
    dataIndex: 'sex',
    customRender: ({ text }) => {
      return render.renderDict(text, 'sex');
    },
  },
  {
    title: userFields.phone,
    align: 'center',
    dataIndex: 'phone',
  },
];

//查询区域
export const searchFormSchema: FormSchema[] = [
  {
    field: 'username',
    label: userFields.username,
    component: 'Input',
    colProps: { span: 6 },
  },
];
